LEADTOOLS GDI/GDI+ (Leadtools.Drawing assembly)
LEAD Technologies, Inc

PaintBuffer(RasterImage,Graphics,LeadRect,LeadRect,LeadRect,LeadRect,Byte[],Int32,Int32,Int32,RasterPaintProperties) Method

Example 





The source image.
The destination System.Drawing.Graphics object where the image data will be displayed.

A Leadtools.LeadRect object that specifies the part of the image to use as the display source.

The coordinates in the srcRect rectangle are relative to the image. You can pass Rectangle.Empty to use the default, which matches the image.

A Leadtools.LeadRect object specifies the portion of the display source to paint. Generally, this is used for updating the display when part of the source image has changed.

The coordinates in the srcClipRect rectangle are relative to the image. You can pass Rectangle.Empty to use the default, which matches the image

A Leadtools.LeadRect object that determines how the source rectangle is scaled and how the image is positioned in the destination graphics object.

The coordinates in the destRect object are relative to the graphics object. There is no default for this parameter. You must specify the Leadtools.LeadRect object.

A Leadtools.LeadRect object that specifies the portion of the display rectangle to paint. Generally, this is used for updating changes in the display surface, such as when a user moves another window, uncovering a part of the image that had been covered up.

The coordinates in the destClipRect are relative to the System.Drawing.Graphics object. You can pass Rectangle.Empty to use the default, which matches the System.Drawing.Graphics object. In most cases, however, you should use the rectangle returned by the .NET PaintEventArgs.ClipRectangle or Windows WM_PAINT message.

The buffer that contains the image data to paint
Offset into buffer where the data starts.
The first row to paint. The painted portion of any row may be limited by the rectangle parameters.

The number of rows to paint. The painted portion of any row may be limited by the rectangle parameters.

If the image data in buffer is compressed 1-bit data, you can specify the number of lines as a negative value (-lines), as explained in Speeding Up 1-Bit Documents.

Options for the display.
Paints image data from a buffer into a System.Drawing.Graphics object.
Syntax
public static void PaintBuffer( 
   RasterImage image,
   Graphics graphics,
   LeadRect srcRect,
   LeadRect srcClipRect,
   LeadRect destRect,
   LeadRect destClipRect,
   byte[] buffer,
   int bufferOffset,
   int row,
   int count,
   RasterPaintProperties properties
)
'Declaration
 
Public Overloads Shared Sub PaintBuffer( _
   ByVal image As RasterImage, _
   ByVal graphics As Graphics, _
   ByVal srcRect As LeadRect, _
   ByVal srcClipRect As LeadRect, _
   ByVal destRect As LeadRect, _
   ByVal destClipRect As LeadRect, _
   ByVal buffer() As Byte, _
   ByVal bufferOffset As Integer, _
   ByVal row As Integer, _
   ByVal count As Integer, _
   ByVal properties As RasterPaintProperties _
) 
'Usage
 
Dim image As RasterImage
Dim graphics As Graphics
Dim srcRect As LeadRect
Dim srcClipRect As LeadRect
Dim destRect As LeadRect
Dim destClipRect As LeadRect
Dim buffer() As Byte
Dim bufferOffset As Integer
Dim row As Integer
Dim count As Integer
Dim properties As RasterPaintProperties
 
RasterImagePainter.PaintBuffer(image, graphics, srcRect, srcClipRect, destRect, destClipRect, buffer, bufferOffset, row, count, properties)
public static void PaintBuffer( 
   RasterImage image,
   Graphics graphics,
   LeadRect srcRect,
   LeadRect srcClipRect,
   LeadRect destRect,
   LeadRect destClipRect,
   byte[] buffer,
   int bufferOffset,
   int row,
   int count,
   RasterPaintProperties properties
)
 function Leadtools.Drawing.RasterImagePainter.PaintBuffer(RasterImage,Graphics,LeadRect,LeadRect,LeadRect,LeadRect,Byte[],Int32,Int32,Int32,RasterPaintProperties)( 
   image ,
   graphics ,
   srcRect ,
   srcClipRect ,
   destRect ,
   destClipRect ,
   buffer ,
   bufferOffset ,
   row ,
   count ,
   properties 
)
public:
static void PaintBuffer( 
   RasterImage^ image,
   Graphics^ graphics,
   LeadRect srcRect,
   LeadRect srcClipRect,
   LeadRect destRect,
   LeadRect destClipRect,
   array<byte>^ buffer,
   int bufferOffset,
   int row,
   int count,
   RasterPaintProperties properties
) 

Parameters

image
The source image.
graphics
The destination System.Drawing.Graphics object where the image data will be displayed.
srcRect

A Leadtools.LeadRect object that specifies the part of the image to use as the display source.

The coordinates in the srcRect rectangle are relative to the image. You can pass Rectangle.Empty to use the default, which matches the image.

srcClipRect

A Leadtools.LeadRect object specifies the portion of the display source to paint. Generally, this is used for updating the display when part of the source image has changed.

The coordinates in the srcClipRect rectangle are relative to the image. You can pass Rectangle.Empty to use the default, which matches the image

destRect

A Leadtools.LeadRect object that determines how the source rectangle is scaled and how the image is positioned in the destination graphics object.

The coordinates in the destRect object are relative to the graphics object. There is no default for this parameter. You must specify the Leadtools.LeadRect object.

destClipRect

A Leadtools.LeadRect object that specifies the portion of the display rectangle to paint. Generally, this is used for updating changes in the display surface, such as when a user moves another window, uncovering a part of the image that had been covered up.

The coordinates in the destClipRect are relative to the System.Drawing.Graphics object. You can pass Rectangle.Empty to use the default, which matches the System.Drawing.Graphics object. In most cases, however, you should use the rectangle returned by the .NET PaintEventArgs.ClipRectangle or Windows WM_PAINT message.

buffer
The buffer that contains the image data to paint
bufferOffset
Offset into buffer where the data starts.
row
The first row to paint. The painted portion of any row may be limited by the rectangle parameters.
count

The number of rows to paint. The painted portion of any row may be limited by the rectangle parameters.

If the image data in buffer is compressed 1-bit data, you can specify the number of lines as a negative value (-lines), as explained in Speeding Up 1-Bit Documents.

properties
Options for the display.
Remarks

If the graphics object has fewer colors than the image, this method dithers the output to that display surface without affecting the actual image data.

If destRect is larger or smaller than the image's actual dimensions, then the image will be scaled to fit destRect.

If the image data in buffer is compressed 1-bit data, you can specify the number of lines as a negative value (-row), as explained in Speeding Up 1-Bit Documents.

The following properties are used from this Leadtools.RasterImage:

Except for the buffer specifications, this method uses source and destination rectangles the same as Paint(RasterImage,Graphics,LeadRect,RasterPaintProperties). For a complete explanation, refer to Paint(RasterImage,Graphics,LeadRect,RasterPaintProperties).

You can call PaintBuffer(RasterImage,Graphics,LeadRect,LeadRect,LeadRect,LeadRect,Byte[],Int32,Int32,Int32,RasterPaintProperties) from a callback procedure to paint an image while it is being loaded.

For more information refer to RasterImage and GDI/GDI+.

For more information, refer to Changing Image Coordinates.

For more information, refer to Handling Palette Changes.

Example
 
Public Sub PaintBufferExample()
      Dim f As New PaintBufferForm()
      f.ShowDialog()
   End Sub

   Class PaintBufferForm
      Inherits Form
      Private image As RasterImage

      Public Sub New()
         ' Load the image
         Dim codecs As New RasterCodecs()

         Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")
         image = codecs.Load(srcFileName)

         Text = "PaintBuffer Example"
      End Sub

      Protected Overrides Sub Dispose(ByVal disposing As Boolean)
         ' Clean up
         If disposing Then
            image.Dispose()
         End If

         MyBase.Dispose(disposing)
      End Sub

      Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
         ' Draw the image fit and center on this form
         Dim destRect As LeadRect = LeadRect.FromLTRB(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Right, ClientRectangle.Bottom)
         destRect = RasterImage.CalculatePaintModeRectangle( _
            image.ImageWidth, _
            image.ImageHeight, _
            destRect, _
            RasterPaintSizeMode.Fit, _
            RasterPaintAlignMode.Center, _
            RasterPaintAlignMode.Center)

         Dim buffer(image.BytesPerLine - 1) As Byte

         image.Access()
         For row As Integer = 0 To image.Height - 1
            image.GetRow(row, buffer, 0, image.BytesPerLine)
            RasterImagePainter.PaintBuffer(image, e.Graphics, LeadRect.Empty, LeadRect.Empty, destRect, LeadRect.Empty, buffer, 0, row, 1, RasterPaintProperties.Default)
            Thread.Sleep(10)
         Next
         image.Release()

         MyBase.OnPaint(e)
      End Sub
   End Class

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void PaintBufferExample()
   {
      PaintBufferForm f = new PaintBufferForm();
      f.ShowDialog();
   }

   class PaintBufferForm : Form
   {
      private RasterImage image;

      public PaintBufferForm()
      {
         // Load the image
         RasterCodecs codecs = new RasterCodecs();

         string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");
         image = codecs.Load(srcFileName);

         Text = "PaintBuffer Example";
      }

      protected override void Dispose(bool disposing)
      {
         // Clean up
         if(disposing)
         {
            image.Dispose();
         }

         base.Dispose(disposing);
      }

      protected override void OnPaint(PaintEventArgs e)
      {
         // Draw the image fit and center on this form
         LeadRect destRect = LeadRect.FromLTRB(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Right, ClientRectangle.Bottom);
         destRect = RasterImage.CalculatePaintModeRectangle(
            image.ImageWidth,
            image.ImageHeight,
            destRect,
            RasterPaintSizeMode.Fit,
            RasterPaintAlignMode.Center,
            RasterPaintAlignMode.Center);

         byte[] buffer = new byte[image.BytesPerLine];

         image.Access();
         for(int row = 0; row < image.Height; row++)
         {
            image.GetRow(row, buffer, 0, image.BytesPerLine);
            RasterImagePainter.PaintBuffer(image, e.Graphics, LeadRect.Empty, LeadRect.Empty, destRect, LeadRect.Empty, buffer, 0, row, 1, RasterPaintProperties.Default);
            Thread.Sleep(10);
         }
         image.Release();

         base.OnPaint(e);
      }
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

RasterImagePainter Class
RasterImagePainter Members
Overload List

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.